import 'package:flutter/material.dart';
import 'package:x3_base_package/x3_base_package.dart';
import 'package:x3_business_core/business_customer/ful_components/business_customer_details_service_ht_tab.dart';

class BusinessCustomerDetailsServiceHt extends StatefulWidget {

  static final String sName = 'BusinessCustomerDetailsServiceHt';

  @override
  _BusinessCustomerDetailsServiceHtState createState() => _BusinessCustomerDetailsServiceHtState();

}

class _BusinessCustomerDetailsServiceHtState extends State<BusinessCustomerDetailsServiceHt> {

  dynamic _arguments;

  BaseTabBarPage _baseTabBarPage;

  @override
  Widget build(BuildContext context) {
    _arguments = BaseRouterUtil.getArguments(context);
    String title = BaseUtils.getKeyData(_arguments, 'title').toString();
    return BaseScaffoldComponent(
      title: title,
      child: _buildContent(),
    );
  }

  Widget _buildContent() {
    return BaseScreenRefreshComponent(
      request: BaseScreenRequestModel('/vip/customer/server/tool/topictype', method: BaseHttpMethodEnum.GET),
      controller: BaseFutureController(),
      builder: (BaseHttpResultModel result) {
        return _buildTabPage(result.data);
      },
    );
  }

  Widget _buildTabPage(List<dynamic> items) {
    String inputApi = BaseUtils.getKeyData(_arguments, 'inputApi').toString();
    String vipId = BaseUtils.getKeyData(_arguments, 'vipId').toString();
    List<BaseTabConfig> _tabs = items.map((e) => BaseTabConfig(text: e['value'], child: BusinessCustomerDetailsServiceHtTab(vipId: vipId, topicTypeId: e['key'], inputApi: inputApi))).toList();
    _baseTabBarPage = BaseTabBarPage(_tabs);
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        _baseTabBarPage.buildTabBar(context),
        Expanded(child: _baseTabBarPage.buildTabView()),
      ],
    );
  }

  @override
  void dispose() {
    _baseTabBarPage?.dispose();
    super.dispose();
  }

}
